home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / mathstud.zip / WMERIT.M < prev    next >
Text File  |  1993-03-23  |  2KB  |  52 lines

  1. function [pg, cg, enbw, sl, wcpl] = wmerit(win)
  2. %[pg, enbw, sl, wcpl] = wmerit(win)
  3. %Computes figures of merit for a window 
  4. %See F. J. Harris, "On the Use of Windows for Harmonic Analysis with
  5. %the Discrete Fourier Transform", Proc. of IEEE, Vol. 66, No. 1, Jan 1978
  6. %win  - is the window
  7. %pg   - processing gain (power)
  8. %cg   - coherent (voltage) gain (normalized to wrect(n) window)
  9. %enbw - equivalent noise bandwidth  (bins)
  10. %sl   - scalloping loss or picket-fence loss (power)
  11. %wcpl - worst case processing loss
  12.  
  13. %       S.Halevy 7/31/92
  14. %       Copyright (c) 1992 by the MathWizards
  15.  
  16. if ~isvector(win)
  17.   error('vector argument is expected')
  18. end
  19. win  = win(:);
  20. n    = length(win);
  21. win /= max(win);         % all figures of merit required a normalized window
  22.  
  23. % CG - coherent voltage gain
  24. %         coherent power gain 
  25. cg = sum(win)/n;
  26.  
  27. % ENBW is measured in DFT bins, each bin has a width of fs/N
  28. % where fs is the sampling frequency and N is the number of points
  29.  
  30. enbw = n*sum(win.^2)/(sum(win).^2);  % equivalent noise bandwidth (in bins)
  31.  
  32.  
  33. % PG processing gain. The ratio of output signal-to-noise ratio (SNR)
  34. % to the input SNR (it is a power ratio not a voltage ratio)
  35.  
  36. pg = 1 ./ enbw;
  37.  
  38.  
  39. % SL is the scalloping loss or picket-fence effect loss. It is the
  40. % loss associated for a sine wave mid-way between two frequency bins
  41. % It represent the maximum reduction in processing gain due to the
  42. % signal frequency
  43. % use -20*log10(sl) to get Harris's results in dB
  44.  
  45. fc = exp(-pi * 1I * (0:n-1)/n);  % mid-way tone
  46. sl = abs(fc * win)/sum(win);              % scalar = row * col
  47.  
  48. % WCPL is the worst case processing loss
  49. % use -20*log10(wcpl) to convert to dB
  50. wcpl = sqrt(pg)*sl;              % sqrt is needed to convert power to volt
  51.  
  52.